package com.myorigin.weblog.common.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;

/**
 * Json工具类
 */
@Slf4j
public class JsonUtil {
    private static final ObjectMapper INSTANCE = new ObjectMapper();
    public static String toJsonString(Object obj) {
        try{
            return INSTANCE.writeValueAsString(obj);
        }catch (JsonProcessingException e){
            //log.error("json序列化异常", e);
            return obj.toString();
        }
        }
    }

